# -*- coding:utf-8 -*-
"""Created By Corvo"""

import time

from const import *
from ..system.base import *

if __name__ == '__main__':
    from client import PingModuleClient


class PingModuleServer(ModuleServerBase):
    """网络诊断模块服务端"""
    __mVersion__ = 1
    __identifier__ = ModuleEnum.identifier

    def __init__(self):
        super(PingModuleServer, self).__init__()
        self.rpc = self.ModuleSystem.CreateRpcModule(self, ModuleEnum.identifier)

    def OnDestroy(self):
        self.rpc.Discard()
        del self.rpc
        super(PingModuleServer, self).OnDestroy()

    @property
    def client(self, target=None):
        # type: (str) -> PingModuleClient
        return self.rpc(target)

    def client_recall(self, target, recall):
        # type: (str, any) -> PingModuleClient
        return self.rpc(target, recall)

    # -----------------------------------------------------------------------------------

    """触发相关"""

    @classmethod
    def OnCheckServerTime(cls):
        # type: () -> float
        """测试服务端时间戳"""
        return time.time()
